﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace T01WPF
{
    /// <summary>
    /// LoginWindow.xaml 的交互逻辑
    /// </summary>
    public partial class LoginWindow : Window
    {
        public LoginWindow()
        {
            InitializeComponent();
        }

        private void LoginButton_Click(object sender, RoutedEventArgs e)
        {
            //获取需要处理的界面控件中的数据
            string username = TxtUsername.Text.Trim();
            string password = Txtpassword.Password.Trim();
            //认证逻辑
            //if (username.Equals("123")&&password.Equals("123"))
            if(UserDao.LoginCheck(username,password)>0)
            {
                MessageBox.Show("登录成功");
                //打开主窗口
                var mainWindow = new MainWindow();
                mainWindow.Title = "用户" + username + "登录";
                mainWindow.Show();
                //关闭主窗口
                this.Close();
            }
            else
            {
                MessageBox.Show("用户名或密码错误！");
            }
        }
    }
}
